/**
 * 由 CoCo 源代码计划解包器解包
 *
 * 模块 ID：511__part-23
 */

"use strict"

import { "511__part-2__L" as L } from "./index__part-2"
import { "511__part-3__P" as P } from "./index__part-3"
import { "511__part-4__G" as G } from "./index__part-4"
import { "511__part-7__lt" as lt } from "./index__part-7"
import { "511__part-8__mt" as mt } from "./index__part-8"
import { "511__part-9__vt" as vt } from "./index__part-9"
import { "511__part-12__Ht" as Ht } from "./index__part-12"
import { "511__part-13__Vt" as Vt } from "./index__part-13"
import { "511__part-14__Yt" as Yt } from "./index__part-14"
import { "511__part-15__Xt" as Xt } from "./index__part-15"
import { "511__part-16__Zt" as Zt } from "./index__part-16"
import { "511__part-17__ue" as ue } from "./index__part-17"
import { "511__part-22__Ce" as Ce } from "./index__part-22"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_$$_src_shared_widget_custom_externalModule from "../../../../../src/shared/widget/custom/external-module"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_674 from "../../../../shared/1531/2584/674"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_672 from "../../../../shared/1531/2584/672"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_675 from "../../../../shared/1531/2584/675"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_673 from "../../../../shared/1531/2584/673"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_681 from "../../../../shared/1531/2584/681"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_680 from "../../../../shared/1531/2584/680"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_671 from "../../../../shared/1531/2584/671"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_21_index from "../../../../shared/1531/2584/21/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_679 from "../../../../shared/1531/2584/679"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_678_index from "../../../../shared/1531/2584/678/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_677_index from "../../../../shared/1531/2584/677/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_38_217_index from "../../../../shared/1531/2584/38/217/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_48_index from "../../../../shared/1531/2584/48/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_28_index from "../../../../shared/1531/2584/28/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_58_index from "../../../../shared/1531/2584/58/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_57_index from "../../../../shared/1531/2584/57/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_40 from "../../../../shared/1531/2584/40"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_27 from "../../../../shared/1531/2584/27"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_676 from "../../../../shared/1531/2584/676"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_15 from "../../../../shared/1531/2584/15"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_$$_src_shared_widget_custom_storage from "../../../../../src/shared/widget/custom/storage"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_$$_src_shared_widget_custom_type from "../../../../../src/shared/widget/custom/type"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_$$_src_shared_widget_custom_load from "../../../../../src/shared/widget/custom/load"
import /* [auto-meaningful-name] */Axios from "axios"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_38_2629 from "../../../../shared/1531/2584/38/2629"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_16_index from "../../../../shared/1531/2584/16/index"
import /* [auto-meaningful-name] */React from "react"
import * as /* [auto-meaningful-name] */_React from "react"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_7 from "../../../../shared/1531/2584/7"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_6 from "../../../../shared/1531/2584/6"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_10_index from "../../../../shared/1531/2584/10/index"
import /* [auto-meaningful-name] */RegeneratorRuntime from "regenerator-runtime"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_296 from "../../../../shared/1531/2584/296"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_25_index from "../../../../shared/1531/2584/25/index"
import * as /* [auto-meaningful-name] */$$_$$_$$_$$_shared_1531_2584_38_217_388 from "../../../../shared/1531/2584/38/217/388"
var Re = {
  x: 0,
  y: 0,
  z: 0
}
$$_$$_$$_$$_shared_1531_2584_38_217_index.a.instance.addEventListener("accelerometerUpdate", function (t) {
  Re = t
})
var Ne = function (t) {
  $$_$$_$$_$$_shared_1531_2584_57_index.a(n, t)
  var e = $$_$$_$$_$$_shared_1531_2584_58_index.a(n)
  function n(t) {
    var r
    $$_$$_$$_$$_shared_1531_2584_27.a(this, n);
    (r = e.call(this)).options = t
    r.emitTimer = undefined
    r.emitReading = function () {
      r.emit("reading")
    }
    return r
  }
  $$_$$_$$_$$_shared_1531_2584_40.a(n, [{
    key: "x",
    get: function () {
      return Re.x
    }
  }, {
    key: "y",
    get: function () {
      return Re.y
    }
  }, {
    key: "z",
    get: function () {
      return Re.z
    }
  }, {
    key: "start",
    value: function () {
      var /* [auto-meaningful-name] */this$options
      if (this.emitTimer) {
        throw new Error("Already started")
      }
      this.emitTimer = setInterval(this.emitReading, (null === (this$options = this.options) || undefined === this$options ? undefined : this$options.frequency) || 60)
    }
  }, {
    key: "stop",
    value: function () {
      clearInterval(this.emitTimer)
      this.emitTimer = null
    }
  }])
  return n
}($$_$$_$$_$$_shared_1531_2584_38_217_388.a)
var Le = {
  x: 0,
  y: -50,
  z: 0
}
$$_$$_$$_$$_shared_1531_2584_38_217_index.a.instance.addEventListener("magnetometerUpdate", function (t) {
  Le = t
})
var De = function (t) {
  $$_$$_$$_$$_shared_1531_2584_57_index.a(n, t)
  var e = $$_$$_$$_$$_shared_1531_2584_58_index.a(n)
  function n(t) {
    var r
    $$_$$_$$_$$_shared_1531_2584_27.a(this, n);
    (r = e.call(this)).options = t
    r.emitTimer = undefined
    r.emitReading = function () {
      r.emit("reading")
    }
    return r
  }
  $$_$$_$$_$$_shared_1531_2584_40.a(n, [{
    key: "x",
    get: function () {
      return Le.x
    }
  }, {
    key: "y",
    get: function () {
      return Le.y
    }
  }, {
    key: "z",
    get: function () {
      return Le.z
    }
  }, {
    key: "start",
    value: function () {
      var /* [auto-meaningful-name] */this$options
      if (this.emitTimer) {
        throw new Error("Already started")
      }
      this.emitTimer = setInterval(this.emitReading, (null === (this$options = this.options) || undefined === this$options ? undefined : this$options.frequency) || 60)
    }
  }, {
    key: "stop",
    value: function () {
      clearInterval(this.emitTimer)
      this.emitTimer = null
    }
  }])
  return n
}($$_$$_$$_$$_shared_1531_2584_38_217_388.a)
function Be() {
  window.Accelerometer = Ne
  window.Magnetometer = De
  $$_$$_$$_$$_shared_1531_2584_38_217_index.a.instance.emitToParent("ready")
  $$_$$_$$_$$_shared_1531_2584_38_217_index.a.instance.addEventListener("shake", function () {
    $$_$$_$$_$$_shared_1531_2584_21_index.emitDeviceShake()
  })
}
var Pe = {
  PHONE_DIALER_WIDGET: L,
  CONTACT_PICKER_WIDGET: P,
  SMS_SERVICE_WIDGET: G,
  DIALOG_WIDGET: lt,
  QRCODE_WIDGET: mt,
  PEDOMETER_WIDGET: vt,
  QR_SCANNER_WIDGET: Ht,
  IMAGE_WIDGET: Vt,
  CANVAS_WIDGET: Yt,
  NEW_BUTTON_WIDGET: Xt,
  INPUT_WIDGET: Zt
}
function Ue() {
  var /* [auto-meaningful-name] */__device_id = "__device_id"
  var e = localStorage.getItem(__device_id)
  if (!e) {
    e = $$_$$_$$_$$_shared_1531_2584_38_2629.a()
    localStorage.setItem(__device_id, e)
  }
  return e
}
function We(t) {
  return He.apply(this, arguments)
}
function He() {
  return (He = $$_$$_$$_$$_shared_1531_2584_7.a(RegeneratorRuntime.mark(function t(e) {
    var /* [auto-meaningful-name] */t$sent
    return RegeneratorRuntime.wrap(function (t) {
      for (;;) {
        switch (t.prev = t.next) {
          case 0:
            t.next = 2
            return Promise.all(e.map(function () {
              var t = $$_$$_$$_$$_shared_1531_2584_7.a(RegeneratorRuntime.mark(function t(e) {
                var /* [auto-meaningful-name] */_t$sent
                return RegeneratorRuntime.wrap(function (t) {
                  for (;;) {
                    switch (t.prev = t.next) {
                      case 0:
                        t.next = 2
                        return Axios.get("".concat(e.cdnUrl, "?t=").concat(Math.random()))
                      case 2:
                        _t$sent = t.sent
                        return t.abrupt("return", $$_$$_$$_$$_shared_1531_2584_6.a($$_$$_$$_$$_shared_1531_2584_6.a({}, e), {}, {
                          code: _t$sent.data
                        }))
                      case 4:
                      case "end":
                        return t.stop()
                    }
                  }
                }, t)
              }))
              return function (e) {
                return t.apply(this, arguments)
              }
            }()))
          case 2:
            t$sent = t.sent
            return t.abrupt("return", t$sent)
          case 4:
          case "end":
            return t.stop()
        }
      }
    }, t)
  }))).apply(this, arguments)
}
function Fe(t, e) {
  return Ve.apply(this, arguments)
}
function Ve() {
  return (Ve = $$_$$_$$_$$_shared_1531_2584_7.a(RegeneratorRuntime.mark(function t(e, n) {
    var r
    var i
    var o
    var a
    var s
    var /* [auto-meaningful-name] */s$type
    var f
    var h
    var p
    return RegeneratorRuntime.wrap(function (t) {
      for (;;) {
        switch (t.prev = t.next) {
          case 0:
            o = function () {
              return (o = $$_$$_$$_$$_shared_1531_2584_7.a(RegeneratorRuntime.mark(function t(e, n) {
                var /* [auto-meaningful-name] */t$sent
                var /* [auto-meaningful-name] */t$sent$types
                var /* [auto-meaningful-name] */t$sent$widget
                return RegeneratorRuntime.wrap(function (t) {
                  for (;;) {
                    switch (t.prev = t.next) {
                      case 0:
                        t.next = 2
                        return $$_$$_$$_$$_$$_src_shared_widget_custom_load.r(n, e.startsWith($$_$$_$$_$$_$$_src_shared_widget_custom_type.a), $$_$$_$$_$$_$$_src_shared_widget_custom_externalModule.require)
                      case 2:
                        t$sent = t.sent
                        t$sent$types = t$sent.types
                        t$sent$widget = t$sent.widget
                        r[e] = t$sent$widget
                        $$_$$_$$_$$_$$_src_shared_widget_custom_storage.a({
                          type: e,
                          types: t$sent$types,
                          code: n
                        })
                      case 7:
                      case "end":
                        return t.stop()
                    }
                  }
                }, t)
              }))).apply(this, arguments)
            }
            i = function (t, e) {
              return o.apply(this, arguments)
            }
            r = {}
            t.next = 5
            return Promise.all(e.map(function (t) {
              var /* [auto-meaningful-name] */t$type = t.type
              var /* [auto-meaningful-name] */t$code = t.code
              return i(t$type, t$code)
            }))
          case 5:
            for (a in n) {
              s = n[a]
              s$type = s.type
              if ($$_$$_$$_$$_$$_src_shared_widget_custom_load.q(s$type)) {
                f = $$_$$_$$_$$_shared_1531_2584_6.a($$_$$_$$_$$_shared_1531_2584_6.a({}, s.attributes), {}, {
                  __widgetId: s.id,
                  __widgetType: s.type,
                  __width: s.size.width,
                  __height: s.size.height
                })
                h = r[s$type]
                p = new h(f)
                $$_$$_$$_$$_shared_1531_2584_21_index.addWidgetInstance(s.id, p)
              }
            }
          case 6:
          case "end":
            return t.stop()
        }
      }
    }, t)
  }))).apply(this, arguments)
}
function Ge(t) {
  for (var e in t) {
    var n = t[e]
    var /* [auto-meaningful-name] */n$type = n.type
    if (Pe[n$type]) {
      var i = $$_$$_$$_$$_shared_1531_2584_6.a($$_$$_$$_$$_shared_1531_2584_6.a({}, n.attributes), {}, {
        __widgetId: n.id,
        __widgetType: n.type,
        __width: n.size.width,
        __height: n.size.height
      })
      var o = new (0, Pe[n$type])(i)
      $$_$$_$$_$$_shared_1531_2584_21_index.addWidgetInstance(n.id, o)
    }
  }
}
function Ye(t) {
  return ze.apply(this, arguments)
}
function ze() {
  return (ze = $$_$$_$$_$$_shared_1531_2584_7.a(RegeneratorRuntime.mark(function t(e) {
    var n
    var /* [auto-meaningful-name] */e$blockCode
    var /* [auto-meaningful-name] */e$shouldOpenEmulator
    var /* [auto-meaningful-name] */e$extensionWidgetList
    var /* [auto-meaningful-name] */e$unsafeExtensionWidgetList
    var /* [auto-meaningful-name] */e$fontFileMap
    var d
    var f
    var /* [auto-meaningful-name] */d$widgetMap
    var p
    var /* [auto-meaningful-name] */t$sent
    var b
    var g
    return RegeneratorRuntime.wrap(function (t) {
      for (;;) {
        switch (t.prev = t.next) {
          case 0:
            if (n = e.id, e$blockCode = e.blockCode, e$shouldOpenEmulator = e.shouldOpenEmulator, e$extensionWidgetList = e.extensionWidgetList, e$unsafeExtensionWidgetList = e.unsafeExtensionWidgetList, e$fontFileMap = e.fontFileMap, d = $$_$$_$$_$$_shared_1531_2584_296.a(e, ["id", "blockCode", "shouldOpenEmulator", "extensionWidgetList", "unsafeExtensionWidgetList", "fontFileMap"]), (f = e.apiToken || e["x-coconut-authorization"] || "") || console.warn("api token not set. some api call may fail."), Ge(d$widgetMap = d.widgetMap), p = [], !(null === e$extensionWidgetList || undefined === e$extensionWidgetList ? undefined : e$extensionWidgetList.length)) {
              t.next = 11
              break
            }
            t.next = 9
            return We(e$extensionWidgetList)
          case 9:
            t$sent = t.sent
            p.push.apply(p, $$_$$_$$_$$_shared_1531_2584_25_index.a(t$sent))
          case 11:
            if ((null === e$unsafeExtensionWidgetList || undefined === e$unsafeExtensionWidgetList ? undefined : e$unsafeExtensionWidgetList.length) && p.push.apply(p, $$_$$_$$_$$_shared_1531_2584_25_index.a(e$unsafeExtensionWidgetList)), !p.length) {
              t.next = 15
              break
            }
            t.next = 15
            return Fe(p, d$widgetMap)
          case 15:
            $$_$$_$$_$$_shared_1531_2584_48_index.b(d)
            if (e$shouldOpenEmulator) {
              Be()
            }
            $$_$$_$$_$$_shared_1531_2584_21_index.initializeRoom({
              workId: n,
              context: {
                authorization: f,
                device: {
                  groupId: Ue(),
                  platform: $$_$$_$$_$$_shared_1531_2584_28_index.l(),
                  origin: "coconut"
                }
              }
            })
            $$_$$_$$_$$_shared_1531_2584_21_index.initializeFontFamily(e$fontFileMap)
            $$_$$_$$_$$_shared_1531_2584_21_index.initializeLocalStorage(n, d.widgetMap)
            $$_$$_$$_$$_shared_1531_2584_21_index.initializeHttpClient(d.widgetMap)
            $$_$$_$$_$$_shared_1531_2584_21_index.initializeCloudDBWidget(d.widgetMap)
            $$_$$_$$_$$_shared_1531_2584_21_index.initializeCloudTableDataMap(d.widgetMap)
            t.next = 25
            return $$_$$_$$_$$_shared_1531_2584_21_index.initializeGridMap(d.widgetMap)
          case 25:
            if (b = Object.values(d.widgetMap), !b.some(function (t) {
              return "EXTENSION_QUILL_RICH_TEXT_WIDGET" === t.type || "UNSAFE_EXTENSION_QUILL_RICH_TEXT_WIDGET" === t.type
            })) {
              t.next = 30
              break
            }
            t.next = 30
            return $$_$$_$$_$$_shared_1531_2584_15.ab("https://static.codemao.cn/appcraft/modules/quilljs/1.3.7/quill.snow.css")
          case 30:
            window.eval = function () {}
            g = $$_$$_$$_$$_shared_1531_2584_21_index.generateAsyncScheduler()
            new Function("Coco", "CocoExtension", "asyncScheduler", "AsyncScheduler", e$blockCode)($$_$$_$$_$$_shared_1531_2584_21_index, $$_$$_$$_$$_$$_src_shared_widget_custom_externalModule, g, $$_$$_$$_$$_shared_1531_2584_21_index.AsyncScheduler)
            $$_$$_$$_$$_shared_1531_2584_21_index.subscribeSensor()
            window.addEventListener("message", function (t) {
              var /* [auto-meaningful-name] */t$data = t.data
              if ("deviceEvent" === t$data.type) {
                $$_$$_$$_$$_shared_1531_2584_21_index.emitEvent.apply($$_$$_$$_$$_shared_1531_2584_21_index, $$_$$_$$_$$_shared_1531_2584_25_index.a(t$data.args))
              }
            })
          case 35:
          case "end":
            return t.stop()
        }
      }
    }, t)
  }))).apply(this, arguments)
}
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_676)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_677_index)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_678_index)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_679)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_671)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_680)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_681)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_672)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_673)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_674)
$$_$$_$$_$$_$$_src_shared_widget_custom_load.s($$_$$_$$_$$_shared_1531_2584_675)
var _a
_a = React.memo(function (t) {
  var e = _React.useState(false)
  var n = $$_$$_$$_$$_shared_1531_2584_10_index.a(e, 2)
  var r = n[0]
  var i = n[1]
  var o = function () {
    var e = $$_$$_$$_$$_shared_1531_2584_7.a(RegeneratorRuntime.mark(function e() {
      return RegeneratorRuntime.wrap(function (e) {
        for (;;) {
          switch (e.prev = e.next) {
            case 0:
              ue()
              e.next = 3
              return Ye(t)
            case 3:
              i(true)
            case 4:
            case "end":
              return e.stop()
          }
        }
      }, e)
    }))
    return function () {
      return e.apply(this, arguments)
    }
  }()
  _React.useEffect(function () {
    o()
  }, [])
  return r ? React.createElement($$_$$_$$_$$_shared_1531_2584_16_index.a, {
    store: $$_$$_$$_$$_shared_1531_2584_48_index.a()
  }, React.createElement(Ce, null)) : null
})
export { _a as "511__part-23___a" }
